home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 659 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: inforamp.net!usenet
  2. From: pcurran@inforamp.net (Peter Curran)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Restrictions on qsort compare function?
  5. Date: Wed, 27 Mar 1996 15:31:46 GMT
  6. Organization: PSC Enterprises
  7. Message-ID: <4jbmgo$qpl@sam.inforamp.net>
  8. References: <4iokop$h4p@lyra.csx.cam.ac.uk> <4iqjar$2m9@usenet.pa.dec.com> <1996Mar21.113301.2622@sq.com> <4it51b$ng8@usenet.pa.dec.com> <1996Mar22.202615.9926@sq.com>
  9. Reply-To: pcurran@inforamp.net
  10. NNTP-Posting-Host: ts9-04.tor.inforamp.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. [I posted a similar article yesterday, but it didn't seem to make it to the
  14. 'net.  Appologize if this is redundant.]
  15.  
  16. On Fri, 22 Mar 1996 20:26:15 GMT in article <1996Mar22.202615.9926@sq.com>
  17.     msb@sq.com (Mark Brader) (Mark Brader) wrote:
  18.  
  19. >#  The function shall return an integer less than, equal to, or greater
  20. >#  than zero if the first argument is considered to be respectively
  21. >#  less than, equal to, or greater than the second.
  22. >> > In other words, it must yield an ordering of the possible data values.
  23. >> > This is only the case if
  24. >> > 1. It is a pure function...
  25. >> > 2. It is antisymmetric (I think that's the right word)...
  26. >> > 3. If is transitive...
  27.  
  28. I have to disagree.  While agreeing that what is stated here was roughly the
  29. intent of the committee, the standard doesn't say it.  (I don't really see the
  30.  
  31. In comparing two values 'a' and 'b', I could specify that I consider 'a' less
  32. than 'b' when ((long) time()) produces an odd number, but 'a' greater than 'b'
  33. otherwise.  I can then write a comparison function that implements this
  34. definition.  I see nothing in this that would violate the standard, but it would
  35. probably break many implementations of qsort().  I cannot imagine any use for
  36. such a comparison definition, but it looks legal to me.
  37.  
  38. I think the standard needs to say that successive results generated by the
  39. comparison function must be mutually consistent.  I won't try to suggest wording
  40. to capture that concept.
  41.  
  42. --
  43. Peter Curran                               pcurran@inforamp.net
  44.  
  45.